<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Asynchronous Queues</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-core.html" title="GLib Core Application Support">
<link rel="prev" href="glib-Thread-Pools.html" title="Thread Pools">
<link rel="next" href="glib-Dynamic-Loading-of-Modules.html" title="Dynamic Loading of Modules">
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="glib.html" title="GLib Overview">
<link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
<link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
<link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
<link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
<link rel="chapter" href="tools.html" title="GLib Tools">
<link rel="index" href="ix01.html" title="Index">
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
<link rel="index" href="ix09.html" title="Index of new symbols in 2.14">
<link rel="index" href="ix10.html" title="Index of new symbols in 2.16">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-Thread-Pools.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-core.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-Dynamic-Loading-of-Modules.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2966151" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id2966777" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="glib-Asynchronous-Queues"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id2966151"></a><span class="refentrytitle">Asynchronous Queues</span>
</h2>
<p>Asynchronous Queues &#8212; asynchronous communication between threads</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">

#include &lt;glib.h&gt;


                    <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a>;
<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a>*        <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-new">g_async_queue_new</a>                   (void);
<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a>*        <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-new-full">g_async_queue_new_full</a>              (<a class="link" href="glib-Datasets.html#GDestroyNotify">GDestroyNotify</a> item_free_func);
<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a>*        <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-ref">g_async_queue_ref</a>                   (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);
void                <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unref">g_async_queue_unref</a>                 (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);
void                <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push">g_async_queue_push</a>                  (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data);
void                <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push-sorted">g_async_queue_push_sorted</a>           (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data,
                                                         <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> func,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-pop">g_async_queue_pop</a>                   (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-try-pop">g_async_queue_try_pop</a>               (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-timed-pop">g_async_queue_timed_pop</a>             (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a> *end_time);
<a class="link" href="glib-Basic-Types.html#gint">gint</a>                <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-length">g_async_queue_length</a>                (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);
void                <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-sort">g_async_queue_sort</a>                  (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> func,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);

void                <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-lock">g_async_queue_lock</a>                  (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);
void                <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unlock">g_async_queue_unlock</a>                (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);
void                <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-ref-unlocked">g_async_queue_ref_unlocked</a>          (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);
void                <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unref-and-unlock">g_async_queue_unref_and_unlock</a>      (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);
void                <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push-unlocked">g_async_queue_push_unlocked</a>         (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data);
void                <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push-sorted-unlocked">g_async_queue_push_sorted_unlocked</a>  (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data,
                                                         <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> func,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-pop-unlocked">g_async_queue_pop_unlocked</a>          (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-try-pop-unlocked">g_async_queue_try_pop_unlocked</a>      (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-timed-pop-unlocked">g_async_queue_timed_pop_unlocked</a>    (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a> *end_time);
<a class="link" href="glib-Basic-Types.html#gint">gint</a>                <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-length-unlocked">g_async_queue_length_unlocked</a>       (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);
void                <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-sort-unlocked">g_async_queue_sort_unlocked</a>         (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> func,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id2966777"></a><h2>Description</h2>
<p>
Often you need to communicate between different threads. In general
it's safer not to do this by shared memory, but by explicit message
passing. These messages only make sense asynchronously for
multi-threaded applications though, as a synchronous operation could as
well be done in the same thread.
</p>
<p>
Asynchronous queues are an exception from most other GLib data
structures, as they can be used simultaneously from multiple threads
without explicit locking and they bring their own builtin reference
counting. This is because the nature of an asynchronous queue is that
it will always be used by at least 2 concurrent threads.
</p>
<p>
For using an asynchronous queue you first have to create one with
<a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-new"><code class="function">g_async_queue_new()</code></a>. A newly-created queue will get the reference
count 1. Whenever another thread is creating a new reference of (that
is, pointer to) the queue, it has to increase the reference count
(using <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-ref"><code class="function">g_async_queue_ref()</code></a>). Also, before removing this reference, the
reference count has to be decreased (using
<a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unref"><code class="function">g_async_queue_unref()</code></a>). After that the queue might no longer exist so
you must not access it after that point.
</p>
<p>
A thread, which wants to send a message to that queue simply calls
<a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push"><code class="function">g_async_queue_push()</code></a> to push the message to the queue.
</p>
<p>
A thread, which is expecting messages from an asynchronous queue
simply calls <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-pop"><code class="function">g_async_queue_pop()</code></a> for that queue. If no message is
available in the queue at that point, the thread is now put to sleep
until a message arrives. The message will be removed from the queue
and returned. The functions <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-try-pop"><code class="function">g_async_queue_try_pop()</code></a> and
<a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-timed-pop"><code class="function">g_async_queue_timed_pop()</code></a> can be used to only check for the presence
of messages or to only wait a certain time for messages respectively.
</p>
<p>
For almost every function there exist two variants, one that locks the
queue and one that doesn't. That way you can hold the queue lock
(acquire it with <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-lock"><code class="function">g_async_queue_lock()</code></a> and release it with
<a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unlock"><code class="function">g_async_queue_unlock()</code></a>) over multiple queue accessing
instructions. This can be necessary to ensure the integrity of the
queue, but should only be used when really necessary, as it can make
your life harder if used unwisely. Normally you should only use the
locking function variants (those without the suffix _unlocked)
</p>
</div>
<div class="refsect1" lang="en">
<a name="id2966938"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id2966948"></a><h3>
<a name="GAsyncQueue"></a>GAsyncQueue</h3>
<a class="indexterm" name="id2966960"></a><pre class="programlisting">typedef struct _GAsyncQueue GAsyncQueue;</pre>
<p>
The <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a> struct is an opaque data structure, which represents
an asynchronous queue. It should only be accessed through the
<code class="function">g_async_queue_*</code> functions.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2966992"></a><h3>
<a name="g-async-queue-new"></a>g_async_queue_new ()</h3>
<a class="indexterm" name="id2967006"></a><pre class="programlisting"><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a>*        g_async_queue_new                   (void);</pre>
<p>
Creates a new asynchronous queue with the initial reference count of 1.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> the new <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2967052"></a><h3>
<a name="g-async-queue-new-full"></a>g_async_queue_new_full ()</h3>
<a class="indexterm" name="id2967067"></a><pre class="programlisting"><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a>*        g_async_queue_new_full              (<a class="link" href="glib-Datasets.html#GDestroyNotify">GDestroyNotify</a> item_free_func);</pre>
<p>
Creates a new asynchronous queue with an initial reference count of 1 and
sets up a destroy notify function that is used to free any remaining
queue items when the queue is destroyed after the final unref.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>item_free_func</code></em>&#160;:</span></p></td>
<td> function to free queue elements
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> the new <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2967147"></a><h3>
<a name="g-async-queue-ref"></a>g_async_queue_ref ()</h3>
<a class="indexterm" name="id2967160"></a><pre class="programlisting"><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a>*        g_async_queue_ref                   (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre>
<p>
Increases the reference count of the asynchronous <em class="parameter"><code>queue</code></em> by 1. You
do not need to hold the lock to call this function.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> the <em class="parameter"><code>queue</code></em> that was passed in (since 2.6)
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2967239"></a><h3>
<a name="g-async-queue-unref"></a>g_async_queue_unref ()</h3>
<a class="indexterm" name="id2967253"></a><pre class="programlisting">void                g_async_queue_unref                 (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre>
<p>
Decreases the reference count of the asynchronous <em class="parameter"><code>queue</code></em> by 1. If
the reference count went to 0, the <em class="parameter"><code>queue</code></em> will be destroyed and the
memory allocated will be freed. So you are not allowed to use the
<em class="parameter"><code>queue</code></em> afterwards, as it might have disappeared. You do not need to
hold the lock to call this function.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2967330"></a><h3>
<a name="g-async-queue-push"></a>g_async_queue_push ()</h3>
<a class="indexterm" name="id2967343"></a><pre class="programlisting">void                g_async_queue_push                  (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre>
<p>
Pushes the <em class="parameter"><code>data</code></em> into the <em class="parameter"><code>queue</code></em>. <em class="parameter"><code>data</code></em> must not be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></p></td>
<td> <em class="parameter"><code>data</code></em> to push into the <em class="parameter"><code>queue</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2967459"></a><h3>
<a name="g-async-queue-push-sorted"></a>g_async_queue_push_sorted ()</h3>
<a class="indexterm" name="id2967475"></a><pre class="programlisting">void                g_async_queue_push_sorted           (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data,
                                                         <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> func,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre>
<p>
Inserts <em class="parameter"><code>data</code></em> into <em class="parameter"><code>queue</code></em> using <em class="parameter"><code>func</code></em> to determine the new
position. 
</p>
<p>
This function requires that the <em class="parameter"><code>queue</code></em> is sorted before pushing on
new elements.
</p>
<p>
This function will lock <em class="parameter"><code>queue</code></em> before it sorts the queue and unlock
it when it is finished.
</p>
<p>
For an example of <em class="parameter"><code>func</code></em> see <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-sort"><code class="function">g_async_queue_sort()</code></a>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></p></td>
<td> the <em class="parameter"><code>data</code></em> to push into the <em class="parameter"><code>queue</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>func</code></em>&#160;:</span></p></td>
<td> the <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc"><span class="type">GCompareDataFunc</span></a> is used to sort <em class="parameter"><code>queue</code></em>. This function
    is passed two elements of the <em class="parameter"><code>queue</code></em>. The function should return
    0 if they are equal, a negative value if the first element
    should be higher in the <em class="parameter"><code>queue</code></em> or a positive value if the first
    element should be lower in the <em class="parameter"><code>queue</code></em> than the second element.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></p></td>
<td> user data passed to <em class="parameter"><code>func</code></em>.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.10
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2967719"></a><h3>
<a name="g-async-queue-pop"></a>g_async_queue_pop ()</h3>
<a class="indexterm" name="id2967732"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            g_async_queue_pop                   (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre>
<p>
Pops data from the <em class="parameter"><code>queue</code></em>. This function blocks until data become
available.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> data from the queue.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2967804"></a><h3>
<a name="g-async-queue-try-pop"></a>g_async_queue_try_pop ()</h3>
<a class="indexterm" name="id2967818"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            g_async_queue_try_pop               (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre>
<p>
Tries to pop data from the <em class="parameter"><code>queue</code></em>. If no data is available, <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> is
returned.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> data from the queue or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, when no data is
available immediately.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2967911"></a><h3>
<a name="g-async-queue-timed-pop"></a>g_async_queue_timed_pop ()</h3>
<a class="indexterm" name="id2967924"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            g_async_queue_timed_pop             (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a> *end_time);</pre>
<p>
Pops data from the <em class="parameter"><code>queue</code></em>. If no data is received before <em class="parameter"><code>end_time</code></em>,
<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> is returned.
</p>
<p>
To easily calculate <em class="parameter"><code>end_time</code></em> a combination of <a class="link" href="glib-Date-and-Time-Functions.html#g-get-current-time"><code class="function">g_get_current_time()</code></a>
and <a class="link" href="glib-Date-and-Time-Functions.html#g-time-val-add"><code class="function">g_time_val_add()</code></a> can be used.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>end_time</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal"><span class="type">GTimeVal</span></a>, determining the final time.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> data from the queue or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, when no data is
received before <em class="parameter"><code>end_time</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2968091"></a><h3>
<a name="g-async-queue-length"></a>g_async_queue_length ()</h3>
<a class="indexterm" name="id2968104"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint">gint</a>                g_async_queue_length                (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre>
<p>
Returns the length of the queue, negative values mean waiting
threads, positive values mean available entries in the
<em class="parameter"><code>queue</code></em>. Actually this function returns the number of data items in
the queue minus the number of waiting threads. Thus a return value
of 0 could mean 'n' entries in the queue and 'n' thread waiting.
That can happen due to locking of the queue or due to
scheduling.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> the length of the <em class="parameter"><code>queue</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2968188"></a><h3>
<a name="g-async-queue-sort"></a>g_async_queue_sort ()</h3>
<a class="indexterm" name="id2968203"></a><pre class="programlisting">void                g_async_queue_sort                  (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> func,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre>
<p>
Sorts <em class="parameter"><code>queue</code></em> using <em class="parameter"><code>func</code></em>. 
</p>
<p>
This function will lock <em class="parameter"><code>queue</code></em> before it sorts the queue and unlock
it when it is finished.
</p>
<p>
If you were sorting a list of priority numbers to make sure the
lowest priority would be at the top of the queue, you could use:
</p>
<div class="informalexample"><pre class="programlisting">
 gint32 id1;
 gint32 id2;
  
 id1 = GPOINTER_TO_INT (element1);
 id2 = GPOINTER_TO_INT (element2);
  
 return (id1 &gt; id2 ? +1 : id1 == id2 ? 0 : -1);
</pre></div>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>func</code></em>&#160;:</span></p></td>
<td> the <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc"><span class="type">GCompareDataFunc</span></a> is used to sort <em class="parameter"><code>queue</code></em>. This
    function is passed two elements of the <em class="parameter"><code>queue</code></em>. The function
    should return 0 if they are equal, a negative value if the
    first element should be higher in the <em class="parameter"><code>queue</code></em> or a positive
    value if the first element should be lower in the <em class="parameter"><code>queue</code></em> than
    the second element. 
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></p></td>
<td> user data passed to <em class="parameter"><code>func</code></em>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.10
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2968391"></a><h3>
<a name="g-async-queue-lock"></a>g_async_queue_lock ()</h3>
<a class="indexterm" name="id2968404"></a><pre class="programlisting">void                g_async_queue_lock                  (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre>
<p>
Acquires the <em class="parameter"><code>queue</code></em>'s lock. After that you can only call the
<code class="function">g_async_queue_*<code class="function">_unlocked()</code></code> function variants on that
<em class="parameter"><code>queue</code></em>. Otherwise it will deadlock.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2968488"></a><h3>
<a name="g-async-queue-unlock"></a>g_async_queue_unlock ()</h3>
<a class="indexterm" name="id2968501"></a><pre class="programlisting">void                g_async_queue_unlock                (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre>
<p>
Releases the queue's lock.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2968557"></a><h3>
<a name="g-async-queue-ref-unlocked"></a>g_async_queue_ref_unlocked ()</h3>
<a class="indexterm" name="id2968573"></a><pre class="programlisting">void                g_async_queue_ref_unlocked          (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_async_queue_ref_unlocked</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>
Increases the reference count of the asynchronous <em class="parameter"><code>queue</code></em> by 1.
</p>
<p>
<em class="parameter"><code>Deprecated</code></em>: Since 2.8, reference counting is done atomically
so <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-ref"><code class="function">g_async_queue_ref()</code></a> can be used regardless of the <em class="parameter"><code>queue</code></em>'s
lock.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2968674"></a><h3>
<a name="g-async-queue-unref-and-unlock"></a>g_async_queue_unref_and_unlock ()</h3>
<a class="indexterm" name="id2968690"></a><pre class="programlisting">void                g_async_queue_unref_and_unlock      (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">g_async_queue_unref_and_unlock</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>
Decreases the reference count of the asynchronous <em class="parameter"><code>queue</code></em> by 1 and
releases the lock. This function must be called while holding the
<em class="parameter"><code>queue</code></em>'s lock. If the reference count went to 0, the <em class="parameter"><code>queue</code></em> will be
destroyed and the memory allocated will be freed.
</p>
<p>
<em class="parameter"><code>Deprecated</code></em>: Since 2.8, reference counting is done atomically
so <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unref"><code class="function">g_async_queue_unref()</code></a> can be used regardless of the <em class="parameter"><code>queue</code></em>'s
lock.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2968807"></a><h3>
<a name="g-async-queue-push-unlocked"></a>g_async_queue_push_unlocked ()</h3>
<a class="indexterm" name="id2968821"></a><pre class="programlisting">void                g_async_queue_push_unlocked         (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre>
<p>
Pushes the <em class="parameter"><code>data</code></em> into the <em class="parameter"><code>queue</code></em>. <em class="parameter"><code>data</code></em> must not be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. This
function must be called while holding the <em class="parameter"><code>queue</code></em>'s lock.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></p></td>
<td> <em class="parameter"><code>data</code></em> to push into the <em class="parameter"><code>queue</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2968944"></a><h3>
<a name="g-async-queue-push-sorted-unlocked"></a>g_async_queue_push_sorted_unlocked ()</h3>
<a class="indexterm" name="id2968961"></a><pre class="programlisting">void                g_async_queue_push_sorted_unlocked  (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data,
                                                         <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> func,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre>
<p>
Inserts <em class="parameter"><code>data</code></em> into <em class="parameter"><code>queue</code></em> using <em class="parameter"><code>func</code></em> to determine the new
position.
</p>
<p>
This function requires that the <em class="parameter"><code>queue</code></em> is sorted before pushing on
new elements.
</p>
<p>
This function is called while holding the <em class="parameter"><code>queue</code></em>'s lock.
</p>
<p>
For an example of <em class="parameter"><code>func</code></em> see <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-sort"><code class="function">g_async_queue_sort()</code></a>.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></p></td>
<td> the <em class="parameter"><code>data</code></em> to push into the <em class="parameter"><code>queue</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>func</code></em>&#160;:</span></p></td>
<td> the <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc"><span class="type">GCompareDataFunc</span></a> is used to sort <em class="parameter"><code>queue</code></em>. This function
    is passed two elements of the <em class="parameter"><code>queue</code></em>. The function should return
    0 if they are equal, a negative value if the first element
    should be higher in the <em class="parameter"><code>queue</code></em> or a positive value if the first
    element should be lower in the <em class="parameter"><code>queue</code></em> than the second element.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></p></td>
<td> user data passed to <em class="parameter"><code>func</code></em>.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.10
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2969204"></a><h3>
<a name="g-async-queue-pop-unlocked"></a>g_async_queue_pop_unlocked ()</h3>
<a class="indexterm" name="id2969218"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            g_async_queue_pop_unlocked          (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre>
<p>
Pops data from the <em class="parameter"><code>queue</code></em>. This function blocks until data become
available. This function must be called while holding the <em class="parameter"><code>queue</code></em>'s
lock.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> data from the queue.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2969297"></a><h3>
<a name="g-async-queue-try-pop-unlocked"></a>g_async_queue_try_pop_unlocked ()</h3>
<a class="indexterm" name="id2969310"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            g_async_queue_try_pop_unlocked      (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre>
<p>
Tries to pop data from the <em class="parameter"><code>queue</code></em>. If no data is available, <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> is
returned. This function must be called while holding the <em class="parameter"><code>queue</code></em>'s
lock.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> data from the queue or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, when no data is
available immediately.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2969410"></a><h3>
<a name="g-async-queue-timed-pop-unlocked"></a>g_async_queue_timed_pop_unlocked ()</h3>
<a class="indexterm" name="id2969424"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a>            g_async_queue_timed_pop_unlocked    (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a> *end_time);</pre>
<p>
Pops data from the <em class="parameter"><code>queue</code></em>. If no data is received before <em class="parameter"><code>end_time</code></em>,
<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> is returned. This function must be called while holding the
<em class="parameter"><code>queue</code></em>'s lock.
</p>
<p>
To easily calculate <em class="parameter"><code>end_time</code></em> a combination of <a class="link" href="glib-Date-and-Time-Functions.html#g-get-current-time"><code class="function">g_get_current_time()</code></a>
and <a class="link" href="glib-Date-and-Time-Functions.html#g-time-val-add"><code class="function">g_time_val_add()</code></a> can be used.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>end_time</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal"><span class="type">GTimeVal</span></a>, determining the final time.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> data from the queue or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, when no data is
received before <em class="parameter"><code>end_time</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2969597"></a><h3>
<a name="g-async-queue-length-unlocked"></a>g_async_queue_length_unlocked ()</h3>
<a class="indexterm" name="id2969611"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint">gint</a>                g_async_queue_length_unlocked       (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre>
<p>
Returns the length of the queue, negative values mean waiting
threads, positive values mean available entries in the
<em class="parameter"><code>queue</code></em>. Actually this function returns the number of data items in
the queue minus the number of waiting threads. Thus a return value
of 0 could mean 'n' entries in the queue and 'n' thread waiting.
That can happen due to locking of the queue or due to
scheduling. This function must be called while holding the <em class="parameter"><code>queue</code></em>'s
lock.</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> the length of the <em class="parameter"><code>queue</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id2969706"></a><h3>
<a name="g-async-queue-sort-unlocked"></a>g_async_queue_sort_unlocked ()</h3>
<a class="indexterm" name="id2969723"></a><pre class="programlisting">void                g_async_queue_sort_unlocked         (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue,
                                                         <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> func,
                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre>
<p>
Sorts <em class="parameter"><code>queue</code></em> using <em class="parameter"><code>func</code></em>. 
</p>
<p>
This function is called while holding the <em class="parameter"><code>queue</code></em>'s lock.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>queue</code></em>&#160;:</span></p></td>
<td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>func</code></em>&#160;:</span></p></td>
<td> the <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc"><span class="type">GCompareDataFunc</span></a> is used to sort <em class="parameter"><code>queue</code></em>. This
    function is passed two elements of the <em class="parameter"><code>queue</code></em>. The function
    should return 0 if they are equal, a negative value if the
    first element should be higher in the <em class="parameter"><code>queue</code></em> or a positive
    value if the first element should be lower in the <em class="parameter"><code>queue</code></em> than
    the second element. 
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</span></p></td>
<td> user data passed to <em class="parameter"><code>func</code></em>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.10
</p>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id2969896"></a><div class="refsect2" lang="en"><a name="id2969897"></a></div>
<hr>
<div class="refsect2" lang="en"><a name="id2969898"></a></div>
</div>
</div>
</body>
</html>
